/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package grupb.upf.XMLObjects.impl;

import java.io.Serializable;
import java.util.Hashtable;
import java.util.Map;

/**
 * <p>This class implements the personal tag management.</p>
 *
 * @version    0.0.1-SNAPSHOT
 * @author     Group B
 */
public final class PersonalTag implements grupb.upf.XMLObjects.Tag,
        Serializable {

    /**
     * The serialVersionUID is created to be able to serialize this class, it's
     * necessary because it will be sent.
     */
    private static final long serialVersionUID = 1L;
    /**
     * The personal tags.
     */
    private String personalTag;
    /**
     * The coordinates of the tag.
     */
     private Map < String, Integer > coordenates = null;
    /**
     * This method allows us to set a personal tag.
     * @param tag The personal tag
     */
    @Override
    public void setTag(final String tag) {
        this.personalTag = tag;
    }
    /**
     * This returns the personal tags.
     * @return the personal tags
     */
    @Override
    public String getTag() {
        return this.personalTag;
    }
    /**
     * This method allows to set the coordinates of personal tag.
     * @param x1 There are four coordinates as is a square
     * @param x2 There are four coordinates as is a square
     * @param y1 There are four coordinates as is a square
     * @param y2 There are four coordinates as is a square
     */
    @Override
    public void setCoordenates(final int x1, final int x2, final int y1,
            final int y2) {

        this.coordenates = new Hashtable < String, Integer > ();
        this.coordenates.put("x1", x1);
        this.coordenates.put("x2", x2);
        this.coordenates.put("y1", y1);
        this.coordenates.put("y2", y2);
    }
    /**
     * This method returns the coordinates of a personal tag.
     * @return The personal tag coordinates
     */
    @Override
    public Map getCoordenates() {
        return this.coordenates;
    }
    /**
     * This method clear the coordinates.
     */
    @Override
    public void clearCoordenates() {
        this.coordenates = null;
    }
    /**
     * This method clears the coordinates and the personal tag.
     */
    @Override
    public void clear() {
        this.personalTag = "";
        if (this.coordenates != null) {
            this.coordenates.clear();
        }
    }
}
